home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- #
- # Initialize or shutdown a PCMCIA ethernet adapter
- #
- # This script should be invoked with two arguments. The first is the
- # action to be taken, either "start", "stop", or "restart". The
- # second is the network interface name.
- #
- # simple version for COL install
- #
-
- usage()
- {
- echo "usage: network [action] [device name]"
- echo " actions: start check stop suspend resume"
- exit 1
- }
-
- if [ $# -lt 2 ] ; then usage ; fi
- ACTION=$1 ; DEVICE=$2
-
- if [ -r /etc/system.cnf ]; then
- # Transceiver selection, for cards that need it -- see 'man ifport'
- IF_PORT=""
- # Use BOOTP [y/n]
- BOOTP="n"
- # IP address
- IPADDR="`get_val CONF_${DEVICE}_IP`"
- # Netmask
- NETMASK="`get_val CONF_${DEVICE}_MASK`"
- # Network address
- NETWORK="`get_val CONF_${DEVICE}_NET`"
- # Broadcast address
- BROADCAST="`get_val CONF_${DEVICE}_BCAST`"
- # Gateway address
- GATEWAY="`get_val CONF_ROUTER1_IP`"
- else
- . /etc/pcmcia/network.opts
- fi
-
- case "$ACTION" in
-
- 'start')
-
- if [ "$IF_PORT" != "" ] ; then
- /sbin/ifport $DEVICE $IF_PORT
- fi
-
- if [ "$IPADDR" != "" ] ; then
-
- # Basic network setup
- if [ "$BROADCAST" != "" ] ; then
- /sbin/ifconfig $DEVICE up $IPADDR broadcast $BROADCAST \
- netmask $NETMASK
- else
- /sbin/ifconfig $DEVICE up $IPADDR netmask $NETMASK
- fi
-
- if [ "$NETWORK" != "" ] ; then
- /sbin/route add -net $NETWORK netmask $NETMASK dev $DEVICE
- elif [ "$GATEWAY" != "" ] ; then
- /sbin/route add $GATEWAY $DEVICE
- fi
-
- if [ "$GATEWAY" != "" ] ; then
- /sbin/route add default gw $GATEWAY metric 1
- fi
- fi
- ;;
-
- 'stop')
-
- if [ "$IPADDR" != "" ] ; then
- /sbin/ifconfig $DEVICE down
- fi
- ;;
-
- 'check')
- ;;
-
- 'restart')
- if [ "$IPADDR" != "" ] ; then
- /sbin/ifconfig $DEVICE down up
- fi
- ;;
-
- 'suspend'|'resume')
- ;;
-
- *)
- usage
- ;;
-
- esac
-
- exit 0
-